﻿using AtomUI.Controls;
using AtomUI.ReactiveUI;
using AtomUI.Theme.Language;
using Avalonia;
using Avalonia.Interactivity;
using Avalonia.Threading;
using ReactiveUI;
using SD.App.Desktop.ViewModels;
using System;
using System.Diagnostics;
using System.Reactive.Disposables;

namespace SD.App.Desktop.Views;

public partial class Login : ReactiveWindow<LoginViewModel>
{
    // 1. 手动定义 ViewModelBindings：绑定生命周期容器（关键修正）
    private readonly CompositeDisposable ViewModelBindings = new CompositeDisposable();

    public Login()
    {
        InitializeComponent();
        this.WhenActivated(_ =>
        {
            // 界面激活
        });
    }

    // View 的 OnClosed 中补充释放 ViewModel
    protected override void OnClosed(EventArgs e)
    {
        base.OnClosed(e);
        ViewModelBindings.Dispose(); // 释放 View 中的绑定
        // ViewModel?.Dispose(); // 释放 ViewModel 中的订阅
    }
}